const type = uni.getSystemInfoSync().uniPlatform
// const BASE_API_APP = (window && window.apiUrl) || 'http://101.132.39.71:8086/wms-admin'	
const BASE_API_APP = (window && window.apiUrl) || 'http://localhost:8086/wms-admin'
// const BASE_URL = (type === 'web' && process.env.NODE_ENV === 'development') ? '/api' : BASE_API_APP
const BASE_URL=BASE_API_APP
console.log(BASE_URL, process.env.NODE_ENV);
function get(url, data, res) {
	request(url, data, res, 'GET')
}

function post(url, data, res) {
	request(url, data, res, 'POST')
}

function request(url, data, res, method) {
	let header = method == 'POST' ? {
		//'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
		//'Content-Type': 'application/json; charset=UTF-8',
		'token': uni.getStorageSync('token'),
		Accept: 'application/json, text/javascript, */*; q=0.01'
	} : {
		'token': uni.getStorageSync('token')
	};
	//let params = method == 'POST' ? JSON.stringify(data) : data;
	uni.request({
		url: BASE_URL + url,
		method,
		header,
		data: {...data, userId: '1004'},
		Token: '2499c60c3c05be53288f2a03c3df9fa0',
		success: (data) => {
			uni.hideLoading()
			res(data.data)
		},
		fail(err) {
			uni.hideLoading()
			console.log(err)
		}
	});
}


export default {
	get: function(url, data, res) {
		return get(url, data, res);
	},
	post: function(url, data, res) {
		return post(url, data, res);
	}
}